import React from 'react';
import { createForm } from 'rc-form';
import { connect } from 'react-redux';
import {Modal, List, InputItem} from 'antd-mobile';

import {withClient} from '../../../hoc';

import MyModal from '../../common/Modal';

@withClient
@createForm()
@connect((state) => ({access_token: state.token.access_token}))
export default class CustomerInformationEdit extends React.Component{
    constructor(props) {
        super(props);
        this.state={
            data: props.data,
        }
    }

    save = () => {
        
    }
    render() {
        const {data} = this.props;
        const { getFieldDecorator, getFieldValue } = this.props.form;

        return (
        <MyModal
            visible={this.props.visible}
            title={'编辑客户资料'}
            leftContent='关闭'
            onCannel={() => { 
                const alertInstance = Modal.alert('退出','当前页面还没有保存，是否确定关闭？', [
                    { text: '取消', onPress: () => alertInstance.close(), style: 'default' },
                    { text: '确定', onPress: () => this.props.onCannel() },
                ]);
            }}
            rightContent={[<span key={'save'} onClick={this.save}>保存</span>]}
        >
        <List className='global-list'>

            {getFieldDecorator('currentCustomerMail', {
                initialValue: data && data.currentEmail,
                rules: [
                    {
                    validator: (rules, value, callback) => {
                        callback();
                    }
                    }
                ]
            })(<InputItem clear placeholder="请填写">
                邮件(现)
            </InputItem>)}

            {getFieldDecorator('currentCustomerPhone', {
                initialValue: data && data.currentTelephone,
                rules: [
                    {
                    validator: (rules, value, callback) => {
                        callback();
                    }
                    }
                ]
            })(<InputItem clear placeholder="请填写">
                电话(现)
            </InputItem>)}

            {getFieldDecorator('currentCustomerAddress', {
                initialValue: data && data.currentAddress,
                rules: [
                    {
                    validator: (rules, value, callback) => {
                        callback();
                    }
                    }
                ]
            })(<InputItem clear placeholder="请填写">
                办公地址(现)
            </InputItem>)}

        </List>        
        </MyModal>
        );
    }
}